home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / PRGMANIA / INITFILE / INITFILE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-25  |  2.9 KB  |  71 lines

  1. /*******************************************************************
  2.  * Fonctions de gestion de fichiers de paramètres (.inf)           *
  3.  *                                                                 *
  4.  * Fichier d'entête (.h)                                           *
  5.  *                                                                 *
  6.  * (C) 1996 - Philippe Castella                                    *
  7.  *                                                                 *
  8.  *******************************************************************/
  9.  
  10. #ifndef __INIPROTO__
  11. #define __INIPROTO__
  12.  
  13. /* Définitions utiles                                              */
  14. #ifndef TRUE
  15. #define TRUE 1
  16. #endif
  17.  
  18. #ifndef FALSE
  19. #define FALSE 0
  20. #endif
  21.  
  22. /* Une ligne du fichier (autre qu'un entête de section) ==>
  23.    NomVariable=valeur                                              */
  24. typedef struct _var
  25. {
  26.     char *VarName;                                /* Nom de la variable              */
  27.     char *VarVal;                                    /* Valeur de la variable           */
  28.     struct _var *NextVar;                    /* Variable suivante               */
  29. } InfVar;
  30.  
  31. /* Liste des sections ==> [Nom de la section]                      */
  32. typedef struct _sect
  33. {
  34.     char *SectionName;                        /* Nom de la Section               */
  35.     InfVar *FirstVar;                            /* Premier élément de la section   */
  36.     struct _sect *NextSection;        /* Section suivante                */
  37. } InfSection;
  38.  
  39. /* Structure d'un fichier .inf                                     */
  40. typedef struct _inf
  41. {
  42.     char *FileName;
  43.     InfSection *FirstSection;
  44. } InitFile;
  45.  
  46. /*-----------------------------------------------------------------*
  47.  * Déclaration des fonctions de la librairie                       *
  48.  *-----------------------------------------------------------------*/
  49.  
  50. /* Fonction d'initialisation (création/ouverture d'un fichier .inf */
  51. InitFile *InfCreate (char *nomFic);
  52.  
  53. /* Fonctions d'écriture des variables d'un fichier .inf            */
  54. void InfWriteBool    (InitFile **strIni, char *section, char *var, short val);
  55. void InfWriteInteger (InitFile **strIni, char *section, char *var, long  val);
  56. void InfWriteString  (InitFile **strIni, char *section, char *var, char *val);
  57.  
  58. /* Fonctions de lecture des variables d'un fichier .inf            */
  59. void InfReadBool    (InitFile *strIni, char *section, char *var, short def, short *val);
  60. void InfReadInteger (InitFile *strIni, char *section, char *var, long  def, long  *val);
  61. void InfReadString  (InitFile *strIni, char *section, char *var, char *def, char  *val);
  62.  
  63. /* Fonction de suppression de variables et de sections             */
  64. void InfDeleteVar     (InitFile **strIni, char *section, char *var);
  65. void InfDeleteSection (InitFile **strIni, char *section);
  66.  
  67. /* Fonction de libération ET de mise à jour !!                     */
  68. void InfFree (InitFile *strIni);
  69.  
  70. #endif
  71. /*******************************************************************/